<template>
    借款名称:
    <input type="text" v-model="info.Bname">
    借款最高额度:
    <input type="text" v-model="info.Min">-
    <input type="text" v-model="info.Max">
    <button @click="PageShow">查询</button>
<table border="1">
    <tr>
        <td>借款编号</td>
        <td>借款名称</td>
        <td>借款年限</td>
        <td>借款最高额度</td>
        <td>借款利息</td>
        <td>操作</td>
    </tr>
    <tr v-for="i in data">
        <td>{{ i.BM_Id }}</td>
        <td>{{ i.BM_Name }}</td>
        <td>{{ i.BM_Year }}</td>
        <td>{{ i.BM_Money}}CNY</td>
        <td>{{i.FKT_Borrow_Money_Interset
.BMI_Year}}年{{ i.FKT_Borrow_Money_Interset
.BMI_Interest }}%</td>
        <td><a href="#" @click="GO(i.BM_Id)">查看明细</a>
        </td>
    </tr>
</table>
<a href="#" @click='PageChange("F")'>首页</a>
<a href="#" @click='PageChange("P")'>上一页</a>
<a href="#" @click='PageChange("N")'>下一页</a>
<a href="#" @click='PageChange("L")'>尾页</a>
当前页数{{ PageInfo.PageIndex }}/{{ PageInfo.PageCount }}
{{ PageInfo.ReCount }}条数据
{{ PageInfo.PageSize
}}
</template>
<script setup lang="ts">
import axios from 'axios';
import {ref,onMounted}from 'vue'
import { useRouter } from 'vue-router';
const router=useRouter()
onMounted(()=>{
    PageShow()
})
const info=ref({
    Bname:'',
    Min:'',
    Max:''
})
const data:any=ref([])
const PageInfo=ref({
    PageIndex:1,
    PageSize:2,
    ReCount:0,
    PageCount:0
})
const PageShow=()=>{
    axios.get('https://localhost:44358/api/Borrow/PageShow',
        {
            params:{
                PageIndex:PageInfo.value.PageIndex,
                PageSize:PageInfo.value.PageSize,
                Bname:info.value.Bname,
                Min:info.value.Min,
                Max:info.value.Max
            }
        }
    ).then(
        res=>{
            data.value=res.data.list
            PageInfo.value.ReCount=res.data.ReCount
            PageInfo.value.PageCount=res.data.PageCount
            console.log(res.data.list);
        }
    ).catch(err=>{
        console.log(err);
    })
}
const PageChange=(msg:string)=>{
    if(msg=='F'){
        PageInfo.value.PageIndex=1
    }
    if(msg=='P'){
        if(PageInfo.value.PageIndex==1){
            alert("已经是第一页")
            return
        }
        PageInfo.value.PageIndex--
    }
    if(msg=='N'){
        if(PageInfo.value.PageIndex==PageInfo.value.PageCount){
            alert("已经是最后一页")
            return
        }
        PageInfo.value.PageIndex++
    }
    if(msg=='L'){
        PageInfo.value.PageIndex=PageInfo.value.PageCount
    }
    PageShow()
    }
    const GO=(BM_Id:number)=>{
    router.push({
        path:'/SelectUserById',
        query:{
            BM_Id:BM_Id
        }
    })
}
</script>